//
//  UserInfoModel.h
//  InviteJob
//
//  Created by LangLang on 17/11/1.
//  Copyright © 2017年 Shui. All rights reserved.
//

#import "UserModel.h"
#import "NSObject+property.h"

@implementation UserModel

//归档（序列化）
-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [self enumerateProperties:^(id key) {
        id value = [self valueForKey:key];
        [aCoder encodeObject:value forKey:key];
    }];
}
//解归档（反序列化）
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if(self = [super init])
    {
        __weak typeof(self) weakSelf = self;
        [self enumerateProperties:^(id key) {
            id value = [aDecoder decodeObjectForKey:key];
            [weakSelf setValue:value forKey:key];
        }];
    }
    return self;
}


+(void)responseObject:(id)responseObject{
    {
        //成功
        UserModel *user     = [[UserModel alloc] init];
        user.user_id        = responseObject[@"datas"][@"user_id"];
        user.user_name      = responseObject[@"datas"][@"user_name"];
        user.on_sale      = responseObject[@"datas"][@"on_sale"];
        user.avatar          = responseObject[@"datas"][@"avatar"];
        user.phone          = responseObject[@"datas"][@"phone"];
        user.email          = responseObject[@"datas"][@"email"];
        user.gender         = responseObject[@"datas"][@"gender"];
        user.age            = responseObject[@"datas"][@"age"];
        user.province       = responseObject[@"datas"][@"province"];
        user.city           = responseObject[@"datas"][@"city"];
        user.area           = responseObject[@"datas"][@"area"];
        user.user_type      = responseObject[@"datas"][@"user_type"];
        user.pwd            = responseObject[@"datas"][@"pwd"];
        user.pay_pwd        = responseObject[@"datas"][@"pay_pwd"];
        user.ticket         = responseObject[@"datas"][@"ticket"];
        user.parent_id      = responseObject[@"datas"][@"parent_id"];
        user.register_time  = responseObject[@"datas"][@"register_time"];
        user.register_ip    = responseObject[@"datas"][@"register_ip"];
        user.token          = responseObject[@"datas"][@"token"];
        user.token_time_out = responseObject[@"datas"][@"token_time_out"];
        user.update_time    = responseObject[@"datas"][@"update_time"];
        user.enabled        = responseObject[@"datas"][@"enabled"];
        user.p_phone        = responseObject[@"datas"][@"p_phone"];
        [UserManager saveUerInfoWithModel:user];
    }
    
}

@end
